package com.example.yls.demoa;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private ArrayList<Student> students = new ArrayList<>();
    private StuAdapter stuAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initStudentArrayList();
        stuAdapter = new StuAdapter(MainActivity.this,students);
        recyclerView = findViewById(R.id.recView);
        recyclerView.setAdapter(stuAdapter);
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(MainActivity.this);
        recyclerView.setLayoutManager(linearLayoutManager);
    }

    private void initStudentArrayList() {
        students.add(new Student(1001,"蔡和弟",18,R.drawable.dog1));
        students.add(new Student(1002,"蔡和弟",18,R.drawable.dog1));
        students.add(new Student(1003,"蔡和弟",18,R.drawable.dog1));
        students.add(new Student(1004,"蔡和弟",18,R.drawable.dog1));




    }
}
